import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DeliveryPlanVO, DeliveryPlanForm, DeliveryPlanQuery } from '@/api/delivery/deliveryPlan/types';

/**
 * 查询发货计划列表
 * @param query
 * @returns {*}
 */

export const listDeliveryPlan = (query?: DeliveryPlanQuery): AxiosPromise<DeliveryPlanVO[]> => {
  return request({
    url: '/delivery/deliveryPlan/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询发货计划详细
 * @param id
 */
export const getDeliveryPlan = (id: string | number): AxiosPromise<DeliveryPlanVO> => {
  return request({
    url: '/delivery/deliveryPlan/' + id,
    method: 'get'
  });
};

/**
 * 新增发货计划
 * @param data
 */
export const addDeliveryPlan = (data: DeliveryPlanForm) => {
  return request({
    url: '/delivery/deliveryPlan',
    method: 'post',
    data: data
  });
};

/**
 * 修改发货计划
 * @param data
 */
export const updateDeliveryPlan = (data: DeliveryPlanForm) => {
  return request({
    url: '/delivery/deliveryPlan',
    method: 'put',
    data: data
  });
};

/**
 * 删除发货计划
 * @param id
 */
export const delDeliveryPlan = (id: string | number | Array<string | number>) => {
  return request({
    url: '/delivery/deliveryPlan/' + id,
    method: 'delete'
  });
};
